home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
27
/
3
/
5
/
HP22D5.ZIP
/
EXTERN
/
MONTH.C
< prev
next >
Wrap
Text File
|
1991-04-16
|
1KB
|
67 lines
#include "extern.h" /* Extensions need these! */
BYTE near months[] = {31,28,31,30,31,30,31,31,30,31,30,31};
/*
** This routine creates a month.
**
** Parameters:
**
** month which month to display
** year which year to display
** startday starting day in that month
** (use convert to figure this out)
**
** To call this function from HyperPAD:
**
** get 1990,1,1,0,0,0,0; -- assemble a dateItem list
** convert it to dateItems; -- normalize (figure out 1st day)
** put makeMonth(1990,1,item 7 of it) into page field 1;
*/
MakeMonth(int NumArgs,HANDLE hMonth,HANDLE hYear,HANDLE hStartDay)
{
register int i,j;
int year,month,numdays,startday;
PTR p,buf;
buf = NewPtr(200);
month = htoi(hMonth) - 1;
year = htoi(hYear);
startday = htoi(hStartDay) - 1;
numdays = (month == 1) ? (year % 4 == 0 && year % 100 != 0 || year % 400 == 0 ? 29 : 28) : months[month];
p = buf;
for (i=0;i<startday;i++) {
for (j=0;j<4;j++) *p++ = ' ';
}
for (j=1;j<=numdays;j++,i++) {
if (i >= 7) {
*p++ = '\r';
i = 0;
}
sprintf(p,"%3d ",j);
p += 4;
}
*p = '\0';
ReturnValue(stoh(buf));
FreePtr(buf);
return(STOP);
}
POOL pascal Pool[] = {
{ "MakeMonth", /* name of the handler */
MakeMonth, /* pointer to the handler */
0, /* reserved */
FUNCTION}, /* this is a handler, not a function */
{ NULL, /* NULLs signify the end of the table */
NULL,
0,
0} };